﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Globalization;
using GeoVision.Addin.Core.Settings;

namespace GeoVision.Addin.Helpers
{
    public static class RegistryHelper
    {
        public static void SaveCurrentLanguage(CultureSettins Lang)
        {
            RegistryKey registry = Registry.LocalMachine.CreateSubKey("SOFTWARE\\SSD");
            if (registry != null)
            {
                registry.SetValue("CurrentLanguage", Lang.CultureName.ToString());
                registry.Close();
            }
        }

        public static CultureInfo ReadCurrentLanguage()
        {
            CultureInfo info = null;
            RegistryKey registry = Registry.LocalMachine.CreateSubKey("SOFTWARE\\SSD");
            if (registry != null)
            {
                string lang = (string)registry.GetValue("CurrentLanguage");
                registry.Close();
                info = new CultureInfo(lang);
                return info;
            }
            else
            {
                return info;
            }
        }

        public static string GetCurrentLanguageString()
        {
            RegistryKey registry = Registry.LocalMachine.CreateSubKey("SOFTWARE\\SSD");
            if (registry != null)
            {
                string lang = (string)registry.GetValue("CurrentLanguage");
                registry.Close();
                
                return lang;
            }
            else
            {
                return string.Empty;
            }
        }
    }
}
